'use strict';
const { Controller } = require('egg');

class cProducts extends Controller {
  // pc
  // 查
  async pc_c_query () {
    const { ctx } = this;
    // console.log(ctx.request, "获取从前端传递过来的参数");
    const result = await ctx.service.sProducts.pc_s_query(ctx?.query ?? {});
    ctx.body = result;
  }

  // 增
  async pc_c_create () {
    console.log('?? - pc_c_create');
    const { ctx } = this;
    const result = await ctx.service.sProducts.pc_s_create(ctx?.request?.body ?? {});
    ctx.body = result;
  }

  // 改
  async pc_c_update () {
    console.log('?? - pc_c_update');
    const { ctx } = this;
    const result = await ctx.service.sProducts.pc_s_update(ctx?.request?.body ?? {});
    ctx.body = result;
  }

  // 删
  async pc_c_delete () {
    console.log('?? - pc_c_delete');
    const { ctx } = this;
    const result = await ctx.service.sProducts.pc_s_delete(ctx?.query ?? {});
    ctx.body = result;
  }

    // 首页商品搜索
    async wa_c_search_products () {
      const { ctx } = this;
      const result = await ctx.service.sProducts.wa_s_search_products(ctx?.query ?? {});
      ctx.body = result;
    }

//   // 详情
  async wa_c_detail () {
    console.log('?? - wa_c_detail');
    const { ctx } = this;
    const result = await ctx.service.sProducts.wa_s_detail(ctx?.query ?? {});
    ctx.body = result;
  }

//   // 批量挂载文件资源
//   async pc_c_batchMount () {
//     console.log('?? - pc_c_batchMount');
//     const { ctx } = this;
//     const result = await ctx.service.sProduct.pc_s_batchMount(ctx?.request?.body ?? {});
//     ctx.body = result;
//   }

//   // 删除商品资源
//   async pc_c_deleteMountProduct () {
//     console.log('?? - pc_c_deleteResources');
//     const { ctx } = this;
//     const result = await ctx.service.sProduct.pc_s_deleteMountProduct(ctx?.request?.body ?? {});
//     ctx.body = result;
//   }


  // wa
//   // 详情
//   async wa_c_query () {
//     const { ctx } = this;
//     const result = await ctx.service.sProduct.wa_s_query(ctx?.query ?? {});
//     ctx.body = result;
//   }

    // 商品查询【小程序端】
    async wa_c_query() {
      const { ctx } = this;
      const result = await ctx.service.sProduct.wa_s_query(ctx?.query ?? {});
      ctx.body = result;
    }

}

module.exports = cProducts;